package principe.demeter.improve;


import java.util.ArrayList;
import java.util.List;

/**
 * @author 龙超
 * @date 2020/7/1 11:00
 * @Description
 */

public class DemeterImprove {
    public static void main(String[] args) {
        CollegeManager manager = new CollegeManager();
        new SchoolManager().printAllEmployee(manager);
    }
}

//学校总部员工表
class Employee {
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

//学院员工类
class CollegeEmployee {
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

//管理学院员工的管理表
class CollegeManager {
    //返回所有员工
    public List<CollegeEmployee> getAllEmployee() {
        List<CollegeEmployee> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            CollegeEmployee collegeEmployee = new CollegeEmployee();
            collegeEmployee.setId("学校员工id=" + i);
            list.add(collegeEmployee);
        }
        return list;
    }

    public void printAllEmployee() {
        List<CollegeEmployee> allEmployee = getAllEmployee();
        for (CollegeEmployee collegeEmployee : allEmployee) {
            System.out.println(collegeEmployee.getId());
        }
    }
}

//学校管理类
//CollegeEmployee不是直接朋友
class SchoolManager {
    //返回总部
    public List<Employee> getAllEmployee() {
        List<Employee> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Employee e = new Employee();
            e.setId("学校总部员工id=" + i);
            list.add(e);
        }
        return list;
    }

    //输出所有信息
    void printAllEmployee(CollegeManager sub) {
        sub.printAllEmployee();
        //获取总部
        List<Employee> list = getAllEmployee();
        System.out.println("---------------总部员工--------------");
        for (Employee employee : list) {
            System.out.println(employee.getId());
        }
    }
}